#pragma once

#include "IThreadable.h"
#include <Windows.h>
#include <memory>

namespace GPUCC
{
	namespace CPU
	{
		class Thread
		{
		public:
			Thread(std::shared_ptr<IThreadable> Logic = std::shared_ptr<IThreadable>(NULL));
			~Thread();

			bool Start(std::shared_ptr<IThreadable> Logic = std::shared_ptr<IThreadable>(NULL));
			void Join(unsigned int Timeout = INFINITE);
			void Stop();
			void StopAndWait();
			
			bool IsRunning();
			unsigned int ThreadId();

		private:
			static unsigned int __stdcall ThreadFunc(void* Arguments);

			HANDLE m_Thread;
			bool m_IsRunning;
			unsigned int m_ThreadId;
			std::shared_ptr<IThreadable> m_Logic;
		};
	}
}